package cn.gd.controller.myDesktop.myNotes;

import cn.gd.pojo.Notes;
import cn.gd.service.myMotes.MyNotesService;
import cn.gd.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/myNotes")
public class MyNotes {
    @Autowired
    private MyNotesService service;

    @GetMapping("/queryAllNotes/{userId}")
    public Result<List<Notes>> queryAllNotes(@PathVariable Integer userId){
        System.out.println(userId);
        return Result.ok(service.queryAllNotes(userId));
    }

    @PutMapping("/updateNotes")
    public Result updateNotes(@RequestBody Notes notes){
        return Result.ok(service.updateNotes(notes));
    }

    @PostMapping("/addNotes")
    public Result addNotes(@RequestBody Notes notes){

        return Result.ok(service.addNotes(notes));
    }
}
